package com.xnyzc.lhy.common.component.config;

import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.*;

/**
 * @author Luoqingwei
 **/
@Configuration
public class TreadPoolConfig {

    @Bean
    public ThreadPoolExecutor threadPoolExecutor(){
        return new ThreadPoolExecutor(10, 20,
                10L, TimeUnit.SECONDS,
                new LinkedBlockingQueue<Runnable>(200),
                new ThreadFactory() {
                    @Override
                    public Thread newThread(@NotNull Runnable r) {
                        return new Thread(r, "SyncToMaitaiThread-%d");
                    }
                }, new ThreadPoolExecutor.CallerRunsPolicy());


    }}
